package club.kingyin.commons.clients;

import club.kingyin.commons.entity.core.Document;
import club.kingyin.commons.response.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.scheduling.annotation.Async;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.concurrent.CompletableFuture;

@FeignClient(value = "ky-blog-pro-search")
//@FeignClient(value = "ky-blog-pro-search", url = "http://test2.kingyin.club:8085")
public interface SearchClient {

    @Async
    @PostMapping(value = "/search/save", headers = {"KY-SERVICE=kingyin is yyds!"})
    CompletableFuture<Result> saveAsync(@RequestBody Document document);

    @Async
    @GetMapping(value = "/search/delete", headers = {"KY-SERVICE=kingyin is yyds!"})
    CompletableFuture<Result> deleteAscyn(@RequestParam("id") String id);

    @PostMapping(value = "/search/save", headers = {"KY-SERVICE=kingyin is yyds!"})
    Result save(@RequestBody Document document);

    @GetMapping(value = "/search/delete", headers = {"KY-SERVICE=kingyin is yyds!"})
    Result delete(@RequestParam("id") String id);

    @PostMapping(value = "/search/update", headers = {"KY-SERVICE=kingyin is yyds!"})
    Result update(@RequestBody Document document);

    @Async
    @PostMapping(value = "/search/update", headers = {"KY-SERVICE=kingyin is yyds!"})
    CompletableFuture<Result> updateAsync(@RequestBody Document document);
}
